package com.bangbang.controller;


import com.bangbang.configresult.Result;
import com.bangbang.configresult.ResultEnum;
import com.bangbang.pojo.TbGroupCourseOrder;
import com.bangbang.service.ITbGroupCourseOrderService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 拼团课程商品订单表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-13
 */
@RestController
@RequestMapping("createGroupOrder")
public class TbGroupCourseOrderController {

    @Autowired
    private ITbGroupCourseOrderService orderService;

    @ApiOperation("完成拼团支付订单流水号填充")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "trade_no",value = "流水号",required = true,paramType = "query"),
            @ApiImplicitParam(name = "out_trade_no",value = "订单号",required = true,paramType = "query")
    })
    @PostMapping("createOrder")                                                  //流水号                                       //订单号
    public Result creatGroupOrder(@RequestParam("trade_no")String trade_no, @RequestParam("out_trade_no")String out_trade_no){
        try {
            TbGroupCourseOrder courseOrder = orderService.getById(out_trade_no);
            courseOrder.setGcoTransactionId(trade_no).setGcoStatus("1");
            orderService.updateById(courseOrder);
        }catch (Exception e){
            e.printStackTrace();
            System.err.println("无此数据");
            throw e;
        }
        return Result.buildResult(ResultEnum.SUCCESS);
    }

}

